package com.dys.testextends;

/**
 * @className: com.dys.testextends.BasePerson
 * @description: com.dys.testextends
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/17 下午10:53
 */
public class BasePerson {
    // 属性封装
    private String name;

    private int age;

    private String gender;

    /**
     * 身高,单位为厘米
     */
    private float height;

    /**
     * 体重,单位为公斤or千克
     */
    private float weight;

    // 方法封装
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return this.age;
    }

    public void setAge(int age) {
        if (age < 0 || age > 150) {
            throw new IllegalArgumentException("Age must be between 0 and 150");
        } else {
            this.age = age;
        }
    }

    public String getGender() {
        return this.gender;
    }

    public void setGender(String gender) {
        if ("男".equals(gender) || "女".equals(gender)) {
            this.gender = gender;
        } else {
            this.gender = "保密";
        }
    }

    public float getHeight() {
        return this.height;
    }

    public void setHeight(float height) {
        if (height < 30.0F || height > 300.F) {
            throw new IllegalArgumentException("Height must be between 30.0F and 300.F");
        } else {
            this.height = height;
        }
    }

    public float getWeight() {
        return this.weight;
    }

    public void setWeight(float weight) {
        if (weight < 2.0f || weight > 800.F) {
            throw new IllegalArgumentException("Weight must be between 2.0f and 800.F");
        } else {
            this.weight = weight;
        }
    }

    public void eat() {
        System.out.println("父类吃饭的方法...");
    }

    public void sleep() {
        System.out.println("父类睡觉的方法...");
    }
}
